package cn.fuxi2022.auth.service.impl;

import cn.fuxi2022.auth.mapper.GroupStudentMapper;
import cn.fuxi2022.auth.service.GroupStudentService;
import cn.fuxi2022.core.utils.PageUtils;
import cn.fuxi2022.core.utils.Query;
import cn.fuxi2022.model.empty.auth.GroupStudent;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 社员表 服务实现类
 * </p>
 *
 * @author Fuxi
 * @since 2022-09-19 22:19:30
 */
@Service
public class GroupStudentServiceImpl extends ServiceImpl<GroupStudentMapper, GroupStudent> implements GroupStudentService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        LambdaQueryWrapper<GroupStudent> wrapper = new LambdaQueryWrapper<>();

        if (ObjectUtils.isNotEmpty(params.get("search"))) {
            wrapper.like(GroupStudent::getMobile, params.get("search"))
                    .or()
                    .eq(GroupStudent::getId, params.get("search"));
        }

        IPage<GroupStudent> page = this.page(
                new Query<GroupStudent>().getPage(params), wrapper
        );

        return new PageUtils(page);
    }
}
